package com.example.nbastar;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.squareup.picasso.Picasso;

public class List_item_ball extends AppCompatActivity implements View.OnClickListener{
    private ImageView img_ball_list;
    private TextView tv_name;
    private TextView tv_description;
    private Bean.Ball ball;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_item_ball);
        findViewById(R.id.btn_zuo).setOnClickListener(this);
        initView();
    }

    private void initView() {
        img_ball_list = (ImageView)findViewById(R.id.img_ball);
   //     tv_name = (TextView)findViewById(R.id.tv_ball_name);
        tv_description = (TextView)findViewById(R.id.tv_description);
        Intent intent = getIntent();
        ball = (Bean.Ball)intent.getSerializableExtra("ball");
       // tv_name.setText(ball.getName());
        tv_description.setText(ball.getDesription());

        LoadImg.Load(List_item_ball.this,"http://192.168.43.21:8080/nbaserver/"+ball.getImg(),img_ball_list);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){
            case R.id.btn_zuo:
                Intent intent =new Intent(List_item_ball.this,List_item.class);
                startActivity(intent);
                break;
        }
    }

    public static class LoadImg {
        public static void Load(Context context, String url, ImageView imageView) {
            Picasso.with(context)
                    .load(url)
                    .into(imageView);
        }



    }
}
